package cn.weirdor.security.common.runer;

import cn.weirdor.security.common.utils.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.web.context.WebServerInitializedEvent;
import org.springframework.context.event.EventListener;
import org.springframework.core.annotation.Order;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

@Component
public class StartEventListener {

    private Logger logger = LoggerFactory.getLogger(StartEventListener.class);


    @Order
    @Async
    @EventListener(WebServerInitializedEvent.class)
    public void onApplicationEvent(WebServerInitializedEvent event) {
        String[] profiles = event.getApplicationContext().getEnvironment().getActiveProfiles();
        String profile = StringUtils.join(profiles);
        logger.info("----项目启动完成，当前使用的环境变量:[{}]----",profile);
    }

}
